package com.example.rabbitmqtest01.config;

import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ToExchangeConfirmCallBack implements RabbitTemplate.ConfirmCallback {
    @Override
    public void confirm(CorrelationData correlationData, boolean ack, String cause) {
        if (ack){
            System.err.println("消息唯一id："+correlationData.getId()+"  成功发送到交换机");
        }else {
            System.err.println("消息唯一id："+correlationData.getId()+"  发送到交换机失败\n失败原因 ： "+cause);
        }
    }
}
